package com.diploma.interaction.service.impl;

import com.diploma.interaction.mapper.WxxcxHdxxMapper;
import com.diploma.interaction.model.User;
import com.diploma.interaction.model.WxxcxHdxx;
import com.diploma.interaction.model.WxxcxHdxxExample;
import com.diploma.interaction.service.HdxxService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

@Service
@Slf4j
public class HdxxServiceImpl implements HdxxService {
    @Resource
    WxxcxHdxxMapper hdxxMapper;

    @Override
    public int deleteById(int id) {
        WxxcxHdxxExample hdxxExample=new WxxcxHdxxExample();
        hdxxExample.createCriteria().andXxxhEqualTo(BigDecimal.valueOf(id));
        return hdxxMapper.deleteByExample(hdxxExample);
    }

    @Override
    public void insertSelective(WxxcxHdxx record) {
        hdxxMapper.insert(record);
    }

    @Override
    public int updateByIdSelective(WxxcxHdxx record, int id) {
        WxxcxHdxxExample hdxxExample=new WxxcxHdxxExample();
        hdxxExample.createCriteria().andXxxhEqualTo(BigDecimal.valueOf(id));
        return hdxxMapper.updateByExampleSelective(record,hdxxExample);
    }

    @Override
    public List<WxxcxHdxx> selectByStaffId(String id) {
        WxxcxHdxxExample hdxxExample=new WxxcxHdxxExample();
        hdxxExample.createCriteria().andSsglyDmEqualTo(id);
        return hdxxMapper.selectByExample(hdxxExample);
    }

    @Override
    public WxxcxHdxx selectByXxxh(int id) {
        WxxcxHdxxExample hdxxExample=new WxxcxHdxxExample();
        hdxxExample.createCriteria().andXxxhEqualTo(BigDecimal.valueOf(id));
        return hdxxMapper.selectByExample(hdxxExample).get(0);
    }

    @Override
    public List<WxxcxHdxx> selectByUser(User user) {
        WxxcxHdxxExample hdxxExample=new WxxcxHdxxExample();
        hdxxExample.createCriteria().andTwrsfzjzlDmEqualTo(user.getSfzjzlDm()).andTwrsfzjhmEqualTo(user.getSfzjhm());
        return hdxxMapper.selectByExample(hdxxExample);
    }


}
